// pages/user/orderDetail/index.js
const app = getApp()
const config = require('../../../utils/config.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    order:null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(app.globalData.order)
    this.setData({
      order: app.globalData.order
    })
  },
  callPhone() {
    wx.makePhoneCall({
      phoneNumber: '110',
    })
  },
  cancelOrder() {
    let token = wx.getStorageSync('token')
    let _this = this
    wx.request({
      url: config.HOST +'/expressOrder/orderCancel',
      data: {
        ExpressOrderId: this.data.order.orderId,
        token:token
      },
      success(res) {
        if(res.data.status==200) {
          wx.showToast({
            title: '已取消',
          })
          _this.setData({
            'order.status' : 4
          })
        }else{
          wx.showToast({
            title: res.data.message,
            icon: 'none'
          })
        }
      }
    })
  }
})